package pub.guoxin.oops.common.mail.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
import pub.guoxin.oops.common.mail.MailConfiguration;
import pub.guoxin.oops.common.mail.service.MailSerivce;

/**
 * Created by guoxin on 17-11-14.
 */
@Service
public class MailSerivceImpl implements MailSerivce {

    @Autowired
    private JavaMailSender mailSender;
    @Autowired
    private MailConfiguration mailConfiguration;

    @Override
    public void sendSimpleMail(String sendTo, String titel, String content) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(mailConfiguration.getUsername());
        message.setTo(sendTo);
        message.setSubject(titel);
        message.setText(content);
        mailSender.send(message);
    }


}
